package vamprest.tools;

public abstract class GpsLocationTools {
	public static double calcDistanceMeters(double latitude1,double longitude1,double latitude2,
			double longitude2) {
		  if (latitude1==latitude2 && longitude1==longitude2) 
			  return 0;
		  double distance = Math.sin(Math.toRadians(latitude1)) * Math.sin(Math.toRadians(latitude2)) 
				  +  Math.cos(Math.toRadians(latitude1)) * Math.cos(Math.toRadians(latitude2)) * Math.cos(Math.toRadians(longitude1-longitude2));
		  distance = Math.acos(distance); 
		  distance = Math.toRadians(distance);
		  if (distance>0) return distance * 111190;
		  return 0;
	}
	
}
